//#include<bits/stdc++.h>
//using namespace std;
//char arr[600][600];
//int main() {
//	int n,  m;
//	cin >> n >> m;
//	for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++)cin >> arr[i][j];
//	int ans = 0;
//	for (int i = 1; i < n; i++)for (int j = 1; j < m; j++)if (arr[i][j] == 'c' && arr[i][j + 1] == 'c' && arr[i + 1][j] == 'p' && arr[i + 1][j + 1] == 'c')
//		ans++;
//	cout << ans;
//}
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL arr[1010];
LL sum = 0;
LL n;
vector<LL>v;
long long f[1010];
const long long xx = 998244353;
set<long long>S;
int main() {
	cin >> n;
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		S.insert(arr[i]);
		f[i] = f[i - 1] * i % xx;
		
	}
	sort(arr+1, arr + n+1,greater<long long>());
	for (long long i = 1; i <= n; i++)
	{
		sum += arr[i]* (n - i)-arr[i]*(i-1);
	}
	long long ans = 1;
	for (int i = 1; i <= n; i++)
	{
		LL num = i;
		while (num <= n && arr[i] == arr[num])
			 num++;
		ans *= f[num - i];
		ans %= xx;
		
		v.push_back(num - i);
		i = num - 1;
	}
	if (v[0]==n)
		;
	else
		ans *= (LL)2;
	cout << sum<<' '<<ans%xx;
}
//#include<bits/stdc++.h>
//using namespace std;
//int main() {
//
//}